const babelCore = require('@babel/core')

const code = `
  var a = ["a", "b", "c"];
  var b = [...a, "foo"];
  var c = foo(...a);
`
const result = babelCore.transformSync(code, {
  plugins: ["@babel/plugin-transform-spread"]
})

console.log(result.code);